import { createReducer } from '../utils/index'
import { FETCH_GOODS_DETAILS_SUCC, FETCH_GOODS_DETAILS_FAIL, ADD_GOODS_CART_SUCC, ADD_GOODS_CART_FAIL } from '../contants/good'

const initialState = {
	goodData: {},
    isFetched: null
}

export default createReducer(initialState, {
	[FETCH_GOODS_DETAILS_SUCC]: (state, payload) => {
        return Object.assign({}, state, {
            'isFetched': true,
            'goodData': payload.data
        })
    },

    [FETCH_GOODS_DETAILS_FAIL]: (state, payload) => {
        return Object.assign({}, state, {
            'isFetched': false,
            'goodData': []
        })
    }
})
